Component({
  /**
   * 组件的属性列表
   */
  properties: {
    like: {
      type: Boolean
    },
    count: {
      type: Number
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
  },

  /**
   * 组件的方法列表
   */
  methods: {
    /**
     * 点击事件
     * @param event 
     */
    handleLike(): void {
      // 自定义时间
      let like = this.properties.like;
      let count = this.properties.count;
      count = like ? count - 1 : count + 1
      this.setData({
        like: !like,
        count: count
      })

      // 激活
      let behavior = this.properties.like ? "like" : "cancel"
      this.triggerEvent("like", {
        behavior: behavior
      })
    }
  }
})
